#include <bits/stdc++.h>
using namespace std;
int main() {
    freopen("candy.in", "r", stdin);
    freopen("candy.out", "w", stdout);
    long long n, l, r;
    cin >> n >> l >> r;
    if (r - l >= n) {
		cout << n-1; return 0;
	}
	if (r % n < l % n) {
		cout << n-1; return 0;
	}
	cout << r % n;
    return 0;
}
